/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './notice';
import * as API from './types';

/** 分页查询公告 GET /notice */
export function noticeGetNoticePageQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.NoticeGetNoticePageParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.noticeGetNoticePage(queryKey[1] as typeof options);
    },
    queryKey: ['noticeGetNoticePage', options],
  });
}

/** 编辑公告 PUT /notice */
export function useNoticeEditNoticeMutation(options?: {
  onSuccess?: (value?: API.ResponseModelObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.noticeEditNotice,
    onSuccess(data: API.ResponseModelObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 新增公告 POST /notice */
export function useNoticeAddNoticeMutation(options?: {
  onSuccess?: (value?: API.ResponseModelObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.noticeAddNotice,
    onSuccess(data: API.ResponseModelObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 删除公告 DELETE /notice */
export function useNoticeDeleteNoticeMutation(options?: {
  onSuccess?: (value?: API.ResponseModelObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.noticeDeleteNotice,
    onSuccess(data: API.ResponseModelObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 查询公告详情 GET /notice/${param0} */
export function noticeGetNoticeDetailQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.NoticeGetNoticeDetailParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.noticeGetNoticeDetail(queryKey[1] as typeof options);
    },
    queryKey: ['noticeGetNoticeDetail', options],
  });
}

/** 查询公告列表 GET /notice/list */
export function noticeGetNoticeListQueryOptions(options: {
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.noticeGetNoticeList(queryKey[1] as typeof options);
    },
    queryKey: ['noticeGetNoticeList', options],
  });
}
